home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Panorama / Panorama - Disk 19D (1987-07-22)(Pacific North-West Amigas Club)[WB].zip / Panorama - Disk 19D (1987-07-22)(Pacific North-West Amigas Club)[WB].adf / PipeHandler1.2 / pipelists.c < prev    next >
C/C++ Source or Header  |  1987-06-28  |  3KB  |  106 lines

  1. /****************************************************************************
  2. **  File:       pipelists.c
  3. **  Program:    pipe-handler - an AmigaDOS handler for named pipes
  4. **  Version:    1.1
  5. **  Author:     Ed Puckett      qix@mit-oz
  6. **
  7. **  Copyright 1987 by EpAc Software.  All Rights Reserved.
  8. **
  9. **  History:    05-Jan-87       Original Version (1.0)
  10. */
  11.  
  12. #include   <exec/types.h>
  13.  
  14. #include   "pipelists.h"
  15.  
  16.  
  17.  
  18. /*---------------------------------------------------------------------------
  19. ** pipelists.c
  20. ** -----------
  21. ** This module contains functions and macros for list manipulation.
  22. ** To use its functions, a PIPELISTNODE must be part of the structure to be
  23. ** inserted in a list.  A list is identified by a PIPELISTHEADER (not a
  24. ** pointer to, but an actual PIPELISTHEADER structure).
  25. **      These routines, as implemented, use the fact that a PIPELISTHEADER
  26. ** and a PIPELISTNODE have the same struture.  Loops are started with the
  27. ** scanning pointer referencing the header.  This makes processing uniform,
  28. ** even when  the list is empty.
  29. **
  30. ** Visible Functions
  31. ** -----------------
  32. **    void  InsertHead (headerp, nodep)
  33. **    void  InsertTail (headerp, nodep)
  34. **    void  Delete     (headerp, nodep)
  35. **
  36. ** Macros (in pipelists.h)
  37. ** -----------------------
  38. **    InitList  (headerp)
  39. **    FirstItem (headerp)
  40. **    NextItem  (nodep)
  41. **
  42. ** Local Functions
  43. ** ---------------
  44. **    - none -
  45. */
  46.  
  47.  
  48.  
  49. /*---------------------------------------------------------------------------
  50. ** Insert the node pointed to by "nodep" at the head (front) of the list
  51. ** identified by "headerp".
  52. */
  53.  
  54. void  InsertHead (headerp, nodep)
  55.  
  56. PIPELISTHEADER  *headerp;
  57. PIPELISTNODE    *nodep;
  58.  
  59. { nodep->next= headerp->head;
  60.   headerp->head= nodep;
  61. }
  62.  
  63.  
  64.  
  65. /*---------------------------------------------------------------------------
  66. ** Insert the node pointed to by "nodep" at the tail (end) of the list
  67. ** identified by "headerp".
  68. */
  69.  
  70. void  InsertTail (headerp, nodep)
  71.  
  72. PIPELISTHEADER  *headerp;
  73. PIPELISTNODE    *nodep;
  74.  
  75. { register PIPELISTNODE  *l;
  76.  
  77.  
  78.   for (l= (PIPELISTNODE *) headerp; l->next != NULL; l= l->next)
  79.     ;
  80.  
  81.   l->next= nodep;
  82.   nodep->next= NULL;
  83. }
  84.  
  85.  
  86.  
  87. /*---------------------------------------------------------------------------
  88. ** Delete the node pointed to by "nodep" from the list identified by
  89. ** "headerp".  If the node is not found in the list, nothing is done.
  90. */
  91.  
  92. void  Delete (headerp, nodep)
  93.  
  94. PIPELISTHEADER  *headerp;
  95. PIPELISTNODE    *nodep;
  96.  
  97. { PIPELISTNODE  *l;
  98.  
  99.  
  100.   for (l= (PIPELISTNODE *) headerp; l->next != NULL; l= l->next)
  101.     if (l->next == nodep)
  102.       { l->next= l->next->next;
  103.         break;
  104.       }
  105. }
  106.